package fr.cephb.joperon.core.bio;

/** An enumeration of organisms */
public enum Organism
	{
	Oryza_sativa
		{
		@Override
		public int getTaxId() { return 4530;}
		@Override
		public String getName() { return "Oryza sativa";}
		@Override
		public int getOperonId() { return 6;}
	
		},
	Gallus_gallus
		{
		@Override
		public int getTaxId() { return 9031;}
		@Override
		public String getName() { return "Gallus gallus";}
		@Override
		public int getOperonId() { return 4;}
		},
	Pan_troglodytes
		{
		@Override
		public int getTaxId() { return 9598;}
		@Override
		public String getName() { return "Pan troglodytes";}
		@Override
		public int getOperonId() { return 5;}
		},
	Homo_sapiens
		{
		@Override
		public int getTaxId() { return 9606;}
		@Override
		public String getName() { return "Homo sapiens";}
		@Override
		public int getOperonId() { return 1;}
		@Override
		public String getTreeLetterCode() {
			return "hsa";
			}
		},
	Sus_scrofa
		{
		@Override
		public int getTaxId() { return 9823;}
		@Override
		public String getName() { return "Sus scrofa";}
		@Override
		public int getOperonId() { return 10;}
		},
	Bos_taurus	
		{
		@Override
		public int getTaxId() { return 9913;}
		@Override
		public String getName() { return "Bos taurus";}
		@Override
		public int getOperonId() { return 9;}
		},
	Mus_musculus
		{
		@Override
		public int getTaxId() { return 10090;}
		@Override
		public String getName() { return "Mus musculus";}
		@Override
		public int getOperonId() { return 2;}
		public String getTreeLetterCode()
			{
			return "mmu";
			}
		},
	Rattus_norvegicus
		{
		@Override
		public int getTaxId() { return 10116;}
		@Override
		public String getName() { return "Rattus norvegicus";}
		@Override
		public int getOperonId() { return 3;}
		},
	Oryza_sativa_indica	
		{
		@Override
		public int getTaxId() { return 39946;}
		@Override
		public String getName() { return "Oryza sativa indica";}
		@Override
		public int getOperonId() { return 7;}
		},
	Oryza_sativa_japonica	
		{
		@Override
		public int getTaxId() { return 39947;}
		@Override
		public String getName() { return "Oryza sativa japonica";}
		@Override
		public int getOperonId() { return 8;}
		},
	UndefinedOrganism	
		{
		@Override
		public int getTaxId() { return 0;}
		@Override
		public String getName() { return "Undefined";}
		@Override
		public int getOperonId() { return 0;}
		}
		
		;
	/** get NCBI taxon ID 9606 for human */
	public abstract int getTaxId();
	/** return id of this organism in operon */
	public abstract int getOperonId();
	/** return the Latin name of this organism */
	public abstract String getName();
		
	
	/** find an organism from its id
	 * @return UndefinedOrganism if not found
	 */
	public static Organism getByOperonId(int code)
		{
		switch(code)
			{
	
			case 6: return Oryza_sativa;
	
			case 4: return Gallus_gallus;
	
			case 5: return Pan_troglodytes;
	
			case 1: return Homo_sapiens;
	
			case 10: return Sus_scrofa;
	
			case 9: return Bos_taurus;
	
			case 2: return Mus_musculus;
	
			case 3: return Rattus_norvegicus;
	
			case 7: return Oryza_sativa_indica;
	
			case 8: return Oryza_sativa_japonica;
	
			default: return UndefinedOrganism;
			}
		}

	public String getTreeLetterCode()
		{
		throw new UnsupportedOperationException("3 letter code not defined for "+getName());
		}
	
	@Override
		public String toString() {
			return getName();
			}
	}
